﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Salient.Web.Administration
{
    public partial class error : WebAdminPage
    {

        public string GetAltText(string altText)
        {
            return (string)GetGlobalResourceObject("GlobalResources", altText);
        }

        public string GetHelpImage()
        {
            if (Directionality == "rtl")
            {
                return Common.GetNormalizedUrl("images/Help.jpg");
            }
            else
            {
                return Common.GetNormalizedUrl("images/HelpIcon_solid.gif");
            }
        }

        protected override void OnInit(EventArgs e)
        {
            if (string.Compare(CurrentRequestUrl, Request.CurrentExecutionFilePath) != 0)
            {
                PushRequestUrl(Request.CurrentExecutionFilePath);
            }

            string htmlText = "<td><img src=\"" + Request.ApplicationPath + "/images/yellowCORNER.gif\" width=\"34\"";
            htmlText = htmlText + " alt=\"" + (string)GetGlobalResourceObject("GlobalResources", "YellowCornerGif") + "\"";
            htmlText = htmlText + " border=\"0\"/></td>";
            if (Directionality == "rtl")
            {
                yellowCornerElement.Text = "";
                yellowCornerElementBIDI.Text = htmlText;
            }
            else
            {
                yellowCornerElement.Text = htmlText;
                yellowCornerElementBIDI.Text = "";
            }

            //linkElement.Text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + Common.GetNormalizedUrl("webAdminStyles.css") + "\"/>";
        }

        public void Page_Load()
        {
            // If a page throws an exception on GET, we should remove it from the stack so that ReturnToPreviousPage doesn't
            // result in an endless loop.
            if (Request.HttpMethod == "GET")
            {
                ClearBadStackPage();
            }

            DataBind();
            if (!Request.IsLocal)
            {
                mv1.ActiveViewIndex = 1;
                button1.Visible = false;
            }

            Exception ex = WebAdminPage.GetCurrentException(Context);
            if (ex != null)
            {
                exceptionMessageLabel0.Visible = true;
                exceptionMessageLabel1.Text = ex.Message + " " + ex.StackTrace;
            }
        }

        public void Page_PreRender()
        {
            Stack stack = (Stack)Session["WebAdminUrlStack"];
            if (stack == null || stack.Count <= 1)
            {
                returnToPrevPagePlaceholder.Visible = false;
            }
        }
    }
}
